Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pod logs operation #50

Merged
merged 5 commits into from
Jul 16, 2019
Merged

Pod logs operation #50

merged 5 commits into from
Jul 16, 2019

Conversation

liberwang1013
Copy link
Contributor

@liberwang1013 liberwang1013 commented Jul 15, 2019

using traits to implements log operation in #30

Liber Wang and others added 2 commits July 15, 2019 21:09
@clux
Copy link
Member

clux commented Jul 15, 2019

Oh, this is really good! Thanks a lot for doing this. Looks like you ran into quite a few special cases. Will try to review this one a bit, as there are a few things I'm a bit unsure about, but overall it looks good.

Copy link
Member

@clux clux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very nice. Have left a suggestion that I think would make it slightly nicer. Lemme know what you think.

let config = config::load_kube_config().expect("failed to load kubeconfig");
let client = APIClient::new(config);

let mypod: &str = "mypod";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get this from arg1?

@@ -58,6 +59,8 @@ impl Api<Object<PodSpec, PodStatus>> {
}
}

impl Log for Api<Object<PodSpec, PodStatus>> {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than having a one line impl for one resource object that every user would need to import the trait of, could we instead:

  • have log always public but unimplemented!() or {} by default
  • have an extra impl Api<Object<PodSpec, PodStatus>> that overrides log

Then you have one less import required for users.

Copy link
Contributor Author

@liberwang1013 liberwang1013 Jul 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I implements log operation in this way, because I hope trait Log can be reused by other developers when they implement their crds.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that makes sense. Either way is fine, it would just be easier for users of the Api to not have to import the extra trait.

fn log(&self, name: &str, lp: &LogParams) -> Result<String> {
Ok(self.log_operation(name, lp)?)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice setup between private and public methods that looks like it allows you to very easily implement the Log trait. Cool pattern. Unfortunately, if you follow do my suggestion, this won't be needed.

@clux
Copy link
Member

clux commented Jul 16, 2019

I'll merge this as it stands, my other point is not important.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants